import { User } from '@/api/';

const account = {
	namespaced: true,
	state: {
		info: {}
	},
	mutations: {
		setAccount(state, payload) {
				state.info = payload;
			}
	},
	actions: {
		async loadInfo(context) {
			//当前账户的id
			let id = sessionStorage.id;
			let { status, data } = await User.info({ id });
			if (status) {
				context.commit('setAccount', data);
			}
			return {status, data }
		},
		async updateInfo(context,payload){
			let { status, msg } = await User.account(payload);
			if (status) {
				context.commit('setAccount',payload);
			}
			return { status,msg }
		}
	},
	getters: {}
}
export default account
